package com.yoki.loginview.doWork;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.yoki.loginview.R;

public class FunctionActivity extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_function);
        NameTb = findViewById(R.id.NameTb);
        PwdTb = findViewById(R.id.PwdTb);
    }

    private EditText NameTb;
    private EditText PwdTb;

    public void Login(View view)
    {
        String UserName = NameTb.getText().toString();
        String Password = PwdTb.getText().toString();
        Log.d("Main","用户名为："+UserName);
        Log.d("Main","密码为："+Password);
        if(UserName.equals(""))
        {
            NameTb.requestFocus();
            Toast.makeText(this,"用户名为空，请输入",Toast.LENGTH_SHORT).show();
        }
        else if(Password.equals(""))
        {
            PwdTb.requestFocus();
            Toast.makeText(this,"密码为空，请输入",Toast.LENGTH_SHORT).show();
        }
        else if(UserName.equals("test") && Password.equals("123456"))
        {
            Toast.makeText(this,"登录成功",Toast.LENGTH_SHORT).show();
        }
        else
        {
            Toast.makeText(this,"登录失败",Toast.LENGTH_SHORT).show();
        }
    }

    public void Clear(View view)
    {
        NameTb.setText("");
        PwdTb.setText("");
    }
}